package com.kgc.storeprovider.service.impl;

import com.kgc.basic.util.ResponseMsg;
import com.kgc.store.pojo.InStoreDetail;
import com.kgc.store.pojo.OutStoreDetail;
import com.kgc.storeprovider.dao.OutStoreDetailMapper;
import com.kgc.storeprovider.service.OutStoreDetailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OutStoreDetailServiceImpl implements OutStoreDetailService {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private OutStoreDetailMapper outStoreDetailMapper;

    @Override
    public ResponseMsg getOutStoreDetailList(String outStoreCode) {
        logger.info("OutStoreDetailServiceImpl getOutStoreDetailList outStoreCode:"+outStoreCode);
        ResponseMsg msg = new ResponseMsg();
        List<OutStoreDetail> outStoreDetailList = outStoreDetailMapper.getOutStoreDetailList(outStoreCode);
        logger.debug("OutStoreDetailServiceImpl getOutStoreDetailList outStoreCode:"+outStoreCode);
        msg.setCode("200");
        msg.setData(outStoreDetailList);
        logger.debug("OutStoreDetailServiceImpl getOutStoreDetailList msg:"+msg);
        return msg;
    }

    @Override
    public ResponseMsg delOutStoreDetail(Integer id) {
        ResponseMsg msg = new ResponseMsg();
        int delCount = outStoreDetailMapper.delOutStoreDetail(id);
        if(delCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }

    @Override
    public ResponseMsg addOutStoreDetail(OutStoreDetail outStoreDetail) {
        ResponseMsg msg = new ResponseMsg();
        int insertCount = outStoreDetailMapper.insertOutStoreDetail(outStoreDetail);
        if(insertCount>0){
            msg.setData(true);
            msg.setCode("200");
        }else{
            msg.setData(false);
            msg.setCode("201");
        }
        return msg;
    }
}
